package ysq.xyg.wxapi.controller;import cn.hutool.core.collection.CollUtil;import cn.hutool.core.util.RandomUtil;import cn.hutool.core.util.StrUtil;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;import com.github.pagehelper.StringUtil;import lombok.extern.slf4j.Slf4j;import org.apache.commons.lang3.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.*;import org.springframework.web.multipart.MultipartFile;import org.springframework.web.servlet.ModelAndView;import ysq.xyg.base.controller.BaseController;import ysq.xyg.base.extend.thread.AsyncManager;import ysq.xyg.base.extend.thread.factory.AsyncFactory;import ysq.xyg.base.model.dto.ReturnEntity;import ysq.xyg.base.util.*;import ysq.xyg.base.util.httpClient.HttpUtil;import ysq.xyg.gaodeapi.GaoDeApi;import ysq.xyg.host.model.po.*;import ysq.xyg.host.model.vo.*;import ysq.xyg.host.service.*;import ysq.xyg.host.util.HostBaseContent;import ysq.xyg.juheapi.JuHeResultVo;import ysq.xyg.juheapi.SmsApi;import ysq.xyg.sys.model.po.SysUser;import ysq.xyg.sys.service.SysFileService;import ysq.xyg.sys.service.SysUserService;import ysq.xyg.web.model.po.*;import ysq.xyg.web.model.vo.*;import ysq.xyg.web.service.*;import ysq.xyg.web.util.WebBaseContent;import ysq.xyg.wxapi.api.WxApiClient;import ysq.xyg.wxapi.api.WxMemoryCacheClient;import ysq.xyg.wxapi.model.base.EwmMessage;import ysq.xyg.wxapi.model.base.JSTicketShareResponse;import ysq.xyg.wxapi.util.QrcodeUtil;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.transaction.Transactional;import java.io.File;import java.io.IOException;import java.text.ParseException;import java.util.*;@Slf4j@RestController@RequestMapping("/weChat")public class WeChatController extends BaseController {    @Autowired    private WebChatService webChatService;    @Autowired    private WebCheckCodeService webCheckCodeService;    @Autowired    private SysUserService sysUserService;    @Autowired    private HostItemService hostItemService;    @Autowired    private HostTypeService hostTypeService;    @Autowired    private WebProductOrderService webProductOrderService;    @Autowired    private WebScoreRecordService webScoreRecordService;    @Autowired    private WebMemberService webMemberService;    @Autowired    private HostSearchService hostSearchService;    @Autowired    private WebArticleService webArticleService;    @Autowired    private HostWithdrawService hostWithdrawService;    @Autowired    private WebShareService webShareService;    @Autowired    private WebBannerService webBannerService;    @Autowired    private WebColumnTypeService webColumnTypeService;    @Autowired    private WebProductService webProductService;    @Autowired    private WebUnionidService webUnionidService;    @Autowired    private HostAreaService hostAreaService;    @Autowired    private HostCityService hostCityService;    @Autowired    private HostDetailService hostDetailService;    @Autowired    private HostReportService hostReportService;    @Autowired    private HostAdviseService hostAdviseService;    @Autowired    private HostSettledService hostSettledService;    @Autowired    private HostApplyService hostApplyService;    @Autowired    private HostCollectService hostCollectService;    @Autowired    private HostWatchService hostWatchService;    @Autowired    private HostShopService hostShopService;    @Autowired    private SysFileService sysFileService;    @Autowired    private WebConfigService webConfigService;    private ModelAndView checkModelAndView;    /**     * 聊天demo     * */    @RequestMapping("/chat")    public ModelAndView chat( HttpServletRequest request,String receiverId,String sendId) throws IOException {        ModelAndView modelAndView = new ModelAndView("/mobile/chat");        modelAndView.addObject("sendId", sendId);        modelAndView.addObject("receiverId", receiverId);        return modelAndView;    }    /**     * 聊天初始化数据     */    @RequestMapping(value = "/chatDate", method = RequestMethod.GET)    public ReturnEntity chatDate(WebChatVo webChatVo){        Map<String, Object> map = new HashMap<String, Object>();        map.put("list", webChatService.listLeft(webChatVo));        map.put("receiverUser",  webMemberService.selectByPrimaryKey(webChatVo.getReceiverSendId()));        return new ReturnEntity(map);    }    /**     * 上传附件     */    @RequestMapping(value = "/sysFile/singleFile",method = RequestMethod.POST)    public @ResponseBody ReturnEntity singleFile(MultipartFile file, HttpServletRequest request, String catalog, String requestFileType, String objectId, String isSave){        return sysFileService.fileUpload(file,request,catalog,requestFileType,objectId,isSave,null);    }    /**     * 首页     * */    @RequestMapping("/index")    public ModelAndView index( HttpServletRequest request,@RequestParam(required = false) String memberId,String cityId) throws IOException {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        // 取第一个城市        HostCity currentCity = hostCityService.selectFirstCity(cityId);        List<HostType> hostTypeList = hostTypeService.acceptList(new HostTypeVo());        ModelAndView modelAndView = new ModelAndView("/mobile/index");        // 设置当前城市        modelAndView.addObject("currentCity", currentCity);        List<WebBanner> webBanners = webBannerService.acceptList(new WebBannerVo(WebBaseContent.WEB_BANNNER_TYPE_SY, BaseConstant.base_use_type_moblie, currentCity.getId()));        modelAndView.addObject("webBannerList", webBanners);        List<WebBanner> hotWebBanners = webBannerService.acceptList(new WebBannerVo(WebBaseContent.WEB_BANNNER_TYPE_SYRM, BaseConstant.base_use_type_moblie, currentCity.getId()));        if (hotWebBanners != null && hotWebBanners.size() > 0) {            modelAndView.addObject("hotWebBanner", hotWebBanners.get(0));        }        // 取第一个热卖文章        WebArticleVo webArticleVo = new WebArticleVo();        webArticleVo.setColId(BaseConstant.WEB_ARTICLE_TYPE_INDEX);        webArticleVo.setCityId(currentCity.getId());        List<WebArticle> webArticles = webArticleService.acceptList(webArticleVo);        if (webArticles != null && webArticles.size() > 0) {            modelAndView.addObject("webArticle", webArticles.get(0));        }        // 设置当前房屋类型        if (hostTypeList != null && hostTypeList.size() > 0) {            modelAndView.addObject("currentHostType", hostTypeList.get(0));        }        // 获取系统配置        List<WebConfig> list = webConfigService.acceptList(new WebConfigVo());        if (CollUtil.isNotEmpty(list)) {            WebConfig webConfig = list.get(0);            if (StringUtils.isNotEmpty(webConfig.getIndexImage())) {                modelAndView.addObject("indexImage", webConfig.getIndexImage());            }        }        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("hostTypeList",hostTypeList);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 城市选择     */    @RequestMapping(value = "/citySelect", method = RequestMethod.GET)    public ReturnEntity citySelect(){        Map<String, Object> map = new HashMap<String, Object>();        // 所有城市        List<CityDTO> citySelect = hostCityService.hostCitySelectList();        map.put("citySelect", citySelect);        // 热门城市        List<CityDataDTO> hotCitySelect = hostCityService.hotHostCityList();        map.put("hotCitySelect", hotCitySelect);        return new ReturnEntity(map);    }    /**     * 楼盘选择     */    @RequestMapping(value = "/cityItemSelect", method = RequestMethod.GET)    public ReturnEntity cityItemSelect(){        Map<String, Object> map = new HashMap<String, Object>();        // 所有城市        List<CityDTO> citySelect = hostItemService.hostItemSelectList();        map.put("citySelect", citySelect);        // 热门城市        List<CityDataDTO> hotCitySelect = hostItemService.hotHostItemSelectList();        map.put("hotCitySelect", hotCitySelect);        return new ReturnEntity(map);    }    /**     * 楼盘信息     */    @RequestMapping("/item")    public ModelAndView item(HttpServletRequest request, @RequestParam(required = false) String memberId, @RequestParam(required = false) String id, String share) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        // 是否已围观过该楼盘        HostWatch hostWatchSearch = new HostWatch();        hostWatchSearch.setItemId(id);        hostWatchSearch.setMemberId(memberId);        HostWatch hostWatch = hostWatchService.selectOne(hostWatchSearch);        if (hostWatch == null) {            // 开启线程去围观该楼盘            AsyncManager.me().execute(AsyncFactory.saveHostWatch(hostWatchSearch));        }        HostItem hostItem = hostItemService.selectLeftObject(new HostItemVo(id));        List<HostWatchVo> hostWatchList = hostWatchService.selectByItemIdAndSize(hostItem.getId(), 20);        // 查看是否收藏过        HostCollect hostCollectSearch = new HostCollect();        hostCollectSearch.setItemId(id);        hostCollectSearch.setMemberId(memberId);        HostCollect hostCollect = hostCollectService.selectOne(hostCollectSearch);        ModelAndView modelAndView = new ModelAndView();        modelAndView.setViewName("/mobile/item");        modelAndView.addObject("hostCollect", hostCollect);        modelAndView.addObject("hostItem", hostItem);        modelAndView.addObject("openTime", cn.hutool.core.date.DateUtil.formatDate(hostItem.getOpenTime()));        modelAndView.addObject("hostWatchList", hostWatchList);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("share", share);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 登录页面     */    @RequestMapping("/loginPage")    public ModelAndView loginPage(HttpServletRequest request, @RequestParam(required = false) String memberId) {        ModelAndView modelAndView = new ModelAndView();        WebMember webMember = webMemberService.selectByPrimaryKey(memberId);        modelAndView.setViewName("/mobile/login");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        return modelAndView;    }    /**     * 注册页面     */    @RequestMapping("/registerPage")    public ModelAndView registerPage(HttpServletRequest request, @RequestParam(required = false) String memberId) {        ModelAndView modelAndView = new ModelAndView();        modelAndView.setViewName("/mobile/register");        modelAndView.addObject("memberId", memberId);        return modelAndView;    }    /**     * 忘记密码     */    @RequestMapping("/repPasswordPage")    public ModelAndView repPasswordPage(HttpServletRequest request, @RequestParam(required = false) String memberId) {        ModelAndView modelAndView = new ModelAndView();        modelAndView.setViewName("/mobile/repPassword");        modelAndView.addObject("memberId", memberId);        return modelAndView;    }    /**     * 登录     */    @RequestMapping(value = "/webMember/login", method = RequestMethod.POST)    public ReturnEntity login(String phone, String password, String memberId){        WebMemberVo webMemberSearch = new WebMemberVo();        webMemberSearch.setPhone(phone);        // md5加密        List<WebMember> list = webMemberService.acceptList(webMemberSearch);        if (list == null || list.size() == 0) {            return new ReturnEntity(BaseConstant.FAIL, "该手机号未注册");        }        WebMember webMember = list.get(0);        if (!StringUtils.equals(webMember.getId(), memberId)) {            return new ReturnEntity(BaseConstant.FAIL, "该手机号被其他人注册");        }        if (!StringUtils.equals(webMember.getPassword(), MD5Util.MD5Encode(password))) {            return new ReturnEntity(BaseConstant.FAIL, "密码不正确");        }        // 登录成功        webMember.setLoginStatus(BaseConstant.WEB_MEMBER_LOGIN_YES);        webMemberService.updateByPrimaryKey(webMember);        return new ReturnEntity();    }    /**     * 忘记密码     */    @RequestMapping(value = "/webMember/repPassword", method = RequestMethod.POST)    public ReturnEntity repPassword(String code, String phone, String password, String memberId){        List<WebCheckCode> list = webCheckCodeService.acceptList(new WebCheckCodeVo(phone, code, BaseConstant.BASE_USE_STATUS_WSY));        if (list != null && list.size() > 0) {            WebCheckCode webCheckCodes = null;            boolean falge = false;            for (WebCheckCode webCheckCode : list) {                if (DateUtil.currentDate().getTime() <= webCheckCode.getEndTime().getTime()) {                    webCheckCodes = webCheckCode;                    falge = true;                }            }            if (falge) {                WebMember webMember = webMemberService.selectByPrimaryKey(memberId);                if (StringUtils.isEmpty(webMember.getPhone())) {                    return new ReturnEntity(BaseConstant.FAIL, "该手机号未注册");                }                if (!StringUtils.equals(webMember.getId(), memberId)) {                    return new ReturnEntity(BaseConstant.FAIL, "该手机号被其他人注册");                }                webMember.setPassword(MD5Util.MD5Encode(password));                int num = webMemberService.updateByPrimaryKey(webMember);                if (num < 0) {                    return new ReturnEntity(BaseConstant.FAIL,"操作失败");                } else {                    if (webCheckCodes != null) {                        webCheckCodes.setUseTime(new Date());                        webCheckCodes.setUseStatus(BaseConstant.BASE_USE_STATUS_YSY);                        webCheckCodeService.updateByPrimaryKey(webCheckCodes);                    }                }                return new ReturnEntity();            } else {                return new ReturnEntity(BaseConstant.FAIL,"验证码已失效");            }        } else {            return new ReturnEntity(BaseConstant.FAIL,"验证码错误");        }    }    /**     * 注册     */    @RequestMapping(value = "/webMember/register", method = RequestMethod.POST)    public ReturnEntity register(String code, WebMember webMember){        // List<WebCheckCode> list = webCheckCodeService.acceptList(new WebCheckCodeVo(webMember.getPhone(), code, BaseConstant.BASE_USE_STATUS_WSY));        ReturnEntity returnEntity = webCheckCodeService.checkCode(webMember.getPhone(), code);        if (returnEntity.getCode() != BaseConstant.SUCCESS) {            return returnEntity;        }        WebCheckCode webCheckCodes = (WebCheckCode)returnEntity.getData();        WebMember webMemberRecord = webMemberService.selectByPrimaryKey(webMember.getId());        if (!StringUtils.equals(webMemberRecord.getId(), webMember.getId())) {            return new ReturnEntity(BaseConstant.FAIL, "该手机号被其他人注册");        }        if (StringUtils.equals(webMember.getCardType(), BaseConstant.WEB_MEMBER_CARD_TYPE_TWO)) {            // 查看验证码是否有效            HostShop hostShopSearch = new HostShop();            hostShopSearch.setNumber(webMember.getShopNumber());            List<HostShop> hostShopList = hostShopService.select(hostShopSearch);            if (hostShopList == null || hostShopList.size() == 0) {                return new ReturnEntity(BaseConstant.FAIL,"未查询到门店验证码，请联系管理员");            }            webMemberRecord.setShopNumber(webMember.getShopNumber());        } else {            webMemberRecord.setShopNumber("");        }        webMemberRecord.setName(webMember.getName());        webMemberRecord.setCardType(webMember.getCardType());        webMemberRecord.setIdCard(webMember.getIdCard());        webMemberRecord.setPhone(webMember.getPhone());        webMemberRecord.setBankNo(webMember.getBankNo());        webMemberRecord.setPassword(MD5Util.MD5Encode(webMember.getPassword()));        int num = webMemberService.updateByPrimaryKey(webMemberRecord);        if (num < 0) {            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        } else {            if (webCheckCodes != null) {                webCheckCodes.setUseTime(new Date());                webCheckCodes.setUseStatus(BaseConstant.BASE_USE_STATUS_YSY);                webCheckCodeService.updateByPrimaryKey(webCheckCodes);            }        }        return new ReturnEntity();    }    /**     * 楼盘详情     */    @RequestMapping("/itemDesc")    public ModelAndView itemDesc(HttpServletRequest request, @RequestParam(required = false) String memberId, @RequestParam(required = false) String id, String share) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        HostItem hostItem = hostItemService.selectLeftObject(new HostItemVo(id));        ModelAndView modelAndView = new ModelAndView();        modelAndView.setViewName("/mobile/itemDesc");        modelAndView.addObject("hostItem",hostItem);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("openTime", cn.hutool.core.date.DateUtil.formatDate(hostItem.getOpenTime()));        // 类型和区域        HostArea hostArea = hostAreaService.selectByPrimaryKey(hostItem.getAreaId());        HostType hostType = hostTypeService.selectByPrimaryKey(hostItem.getHostType());        modelAndView.addObject("hostArea", hostArea.getName());        modelAndView.addObject("hostType", hostType.getName());        modelAndView.addObject("share", share);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的收藏     */    @RequestMapping("/myCollect")    public ModelAndView myCollect(HttpServletRequest request, @RequestParam(required = false) String memberId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView();        modelAndView.setViewName("/mobile/myCollect");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 收藏分页     */    @RequestMapping(value = "/hostCollect/page",method = RequestMethod.POST)    public ReturnEntity hostCollectPage(HostCollectVo hostCollectVo, int pageSize, int pageNum){        ReturnEntity returnEntity = hostCollectService.pageDtoLeft(hostCollectVo, pageSize, pageNum);        return returnEntity;    }    /**     * 收藏     */    @RequestMapping(value = "/hostCollect/save",method = RequestMethod.POST)    public ReturnEntity hostCollect(String itemId, String memberId){        // 先查询是否已收藏        HostCollect hostCollectSearch = new HostCollect();        hostCollectSearch.setItemId(itemId);        hostCollectSearch.setMemberId(memberId);        HostCollect hostCollect = hostCollectService.selectOne(hostCollectSearch);        if (hostCollect != null) {            return new ReturnEntity(BaseConstant.FAIL, "您已收藏过该楼盘");        }        hostCollect = new HostCollect();        hostCollect.setId(BaseUtil.uId());        hostCollect.setItemId(itemId);        hostCollect.setMemberId(memberId);        hostCollect.setCreateTime(new Date());        hostCollect.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        hostCollectService.insert(hostCollect);        return new ReturnEntity();    }    /**     * 取消收藏     */    @RequestMapping(value = "/hostCollect/cancelCollect",method = RequestMethod.POST)    public ReturnEntity cancelCollect(String id){        hostCollectService.deleteByPrimaryKey(id);        return new ReturnEntity();    }    /**     * 查询围观总人数及推荐人数     */    @RequestMapping(value = "/hostWatch/selectCount",method = RequestMethod.POST)    public ReturnEntity selectCount(String itemId){        HostWatch hostWatch = new HostWatch();        hostWatch.setItemId(itemId);        int count = hostWatchService.selectCount(hostWatch);        int reportCount = hostReportService.selectCountByItemId(itemId);        Map<String, Object> map = new HashMap<String, Object>();        map.put("watchCount", count);        map.put("reportCount", reportCount);        return new ReturnEntity(map);    }    /**     * 推荐用户     */    @RequestMapping("/customerEdit")    public ModelAndView customerEdit(HttpServletRequest request,@RequestParam(required = false) String memberId, String itemId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/customerEdit");        HostItem hostItem = hostItemService.selectByPrimaryKey(itemId);        modelAndView.addObject("currentHostItem", hostItem);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("currentDate", DateUtil.currentDate());        modelAndView.addObject("itemId", itemId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 推荐用户，全部楼盘选择     */    @RequestMapping("/allCustomerEdit")    public ModelAndView allCustomerEdit(HttpServletRequest request,@RequestParam(required = false) String memberId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/allCustomerEdit");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("currentDate", DateUtil.currentDate());        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我推荐的用户     */    @RequestMapping("/myCustomerList")    public ModelAndView myCustomerList(HttpServletRequest request,@RequestParam(required = false) String memberId, String status) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/myCustomerList");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("currentDate", DateUtil.currentDate());        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("status", status);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 小区详情     */    @RequestMapping("/xq")    public ModelAndView xq(HttpServletRequest request,@RequestParam(required = false) String memberId,@RequestParam(required = false) String id,String share) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        HostItem hostItem= hostItemService.selectLeftObject(new HostItemVo(id));        List<HostSettled> hostSettledList=hostSettledService.listLeft(new HostSettledVo(hostItem.getId(),"",BaseConstant.BASE_CHECK_STATUS_YSH));        ModelAndView modelAndView = new ModelAndView();        //分享：1、系统进入，2、分享进入（我要分享隐藏，当前分享人为经纪人，联系人只显示当前分享经纪人，否则，显示区域经纪人）        if("2".equals(share)){            modelAndView.setViewName("/mobile/xqShare");        }else{            modelAndView.setViewName("/mobile/xq");        }        modelAndView.addObject("hostItem",hostItem);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("share", share);        modelAndView.addObject("hostSettledList", hostSettledList);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 房屋信息     */    @RequestMapping("/fwxx")    public ModelAndView fwxx(HttpServletRequest request,@RequestParam(required = false) String memberId,String cityId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        HostCity hostCity=hostCityService.selectByPrimaryKey(cityId);        ModelAndView modelAndView = new ModelAndView("/mobile/fwxx");        //获取区域        List<HostArea> hostAreaList=hostAreaService.acceptList(new HostAreaVo(cityId));        if(hostAreaList!=null&&hostAreaList.size()>0){            modelAndView.addObject("currentArea", hostAreaList.get(0));            List<Map<String,String>> areaSelect=new ArrayList<Map<String, String>>();            Map<String,String> mapA=new HashMap<String, String>();            mapA.put("title","全部");            mapA.put("value","");            areaSelect.add(mapA);            for(HostArea hostArea:hostAreaList){                Map<String,String> map=new HashMap<String, String>();                map.put("title",hostArea.getName());                map.put("value",hostArea.getId());                areaSelect.add(map);            }            modelAndView.addObject("areaSelect", JSONArray.toJSONString(areaSelect));        }        List<HostType> hostTypeList=hostTypeService.acceptList(new HostTypeVo());        //设置当前房屋类型        if(hostTypeList!=null&&hostTypeList.size()>0){            modelAndView.addObject("currentHostType", hostTypeList.get(0));        }        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("hostCity", hostCity);        modelAndView.addObject("cityId", cityId);        modelAndView.addObject("hostTypeList",hostTypeList);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我要报备     */    @RequestMapping("/bbkh")    public ModelAndView bbkh(HttpServletRequest request,@RequestParam(required = false) String memberId,String cityId,String itemId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/bbkh");        HostItem hostItem = hostItemService.selectByPrimaryKey(itemId);        modelAndView.addObject("currentHostItem", hostItem);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("currentDate", DateUtil.currentDate());        modelAndView.addObject("cityId", cityId);        modelAndView.addObject("itemId", itemId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 积分商城     */    @RequestMapping("/jfsc")    public ModelAndView jfsc(HttpServletRequest request,@RequestParam(required = false) String memberId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/jfsc");        List<WebProduct> webProductList=webProductService.acceptList(new WebProductVo(BaseConstant.base_show_type_zs,BaseConstant.base_show_type_zs));        List<WebColumnType> webColumnTypeList=webColumnTypeService.acceptList(new WebColumnTypeVo(WebBaseContent.web_col_type_product));        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webColumnTypeList", webColumnTypeList);        modelAndView.addObject("webProductList", webProductList);        modelAndView.addObject("webBannerList",webBannerService.acceptList(new WebBannerVo(WebBaseContent.WEB_BANNNER_TYPE_JF,BaseConstant.base_use_type_moblie,"")));        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 商品详情     */    @RequestMapping("/productDesc")    public ModelAndView productDesc(HttpServletRequest request,@RequestParam(required = false) String memberId,String id) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/productDesc");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("product", webProductService.selectByPrimaryKey(id));        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 客户     */    @RequestMapping("/kh")    public ModelAndView kh(HttpServletRequest request,@RequestParam(required = false) String memberId,String reportState) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/kh");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("reportState", reportState);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的     */    @RequestMapping("/my")    public ModelAndView my(HttpServletRequest request, @RequestParam(required = false) String memberId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/my");        // 需要报备数量        int one = hostReportService.selectCountByStatus(memberId, BaseConstant.HOST_REPORT_STATE_ONE);        int two = hostReportService.selectCountByStatus(memberId, BaseConstant.HOST_REPORT_STATE_TWO);        int three = hostReportService.selectCountByStatus(memberId, BaseConstant.HOST_REPORT_STATE_THREE);        int four = hostReportService.selectCountByStatus(memberId, BaseConstant.HOST_REPORT_STATE_FOUR);        modelAndView.addObject("one", one);        modelAndView.addObject("two", two);        modelAndView.addObject("three", three);        modelAndView.addObject("four", four);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的信息     */    @RequestMapping("/myEdit")    public ModelAndView myEdit(HttpServletRequest request, @RequestParam(required = false) String memberId) {        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView = new ModelAndView("/mobile/myEdit");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 申请经纪人     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/sqjjr")    public ModelAndView sqjjr(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        List<HostApply> hostApplyList=hostApplyService.acceptList(new HostApplyVo(memberId));        ModelAndView modelAndView=new ModelAndView("/mobile/sqjjr");        if(hostApplyList!=null&&hostApplyList.size()>0){            modelAndView.addObject("hostApply", hostApplyList.get(0));        }        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 建议     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/advise")    public ModelAndView advise(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/advise");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 佣金明细     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/detail")    public ModelAndView detail(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        // 可提现。member表中金额，已提现和提现中，查询提现表，累计，总金额相加        int dtx = hostWithdrawService.selectSumMoney(memberId, HostBaseContent.HOST_WITHDRAW_STATUS_DTX);        int txcg = hostWithdrawService.selectSumMoney(memberId, HostBaseContent.HOST_WITHDRAW_STATUS_TXCG);        ModelAndView modelAndView = new ModelAndView("/mobile/wdyj");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("dtx", dtx);        modelAndView.addObject("txcg", txcg);        modelAndView.addObject("allMoney", dtx + txcg + webMember.getMoney());        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 文章页面     *     * @param id 文章标识     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/article")    public ModelAndView articleDesc(HttpServletRequest request,String id,@RequestParam(required = false) String memberId){        ModelAndView modelAndView=new ModelAndView("/mobile/articleDesc");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("article",webArticleService.selectByPrimaryKey(id));        return modelAndView;    }    /**     * 提现     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/tixian")    public ModelAndView tixian(HttpServletRequest request, String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/tixian");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的提现     *     * @param webMemberVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @author shengQiang yu     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/myMember/page",method = RequestMethod.POST)    public ReturnEntity myMemberPage(WebMemberVo webMemberVo, int pageSize, int pageNum){        ReturnEntity returnEntity = webMemberService.page(webMemberVo,pageSize,pageNum);        return returnEntity;    }    /**     * 我的名片     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/wdmp")    public ModelAndView wdmp(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/wdmp");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 提现详情     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/tixianList")    public ModelAndView tixianList(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/tixianList");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的名片     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/share")    public ModelAndView share(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        //获取相对路径        String realPath= HttpUtil.getRealPath(request);        String url="upload/share/"+memberId+"ewm.png";        File file =new File(realPath+url);        if(!file.exists()){            //如果文件夹不存在则创建            File dicFile =new File(realPath+"upload/share/");            if  (!dicFile .exists()  && !dicFile .isDirectory()){                dicFile.mkdir();            }            WebAccount wxAccountInfo = WxMemoryCacheClient.getSingleWxAccountInfo();            //公众号首页            try {                QrcodeUtil.qrcode(wxAccountInfo.getBaseUrl()+ProProperties.getInstance().getWxOauthAcceptOpenidURL()+"?params="+webMember.getCardNo(),realPath+"upload/share/"+memberId+"ewm.png");            } catch (Exception e) {            }        }        ModelAndView modelAndView=new ModelAndView("/mobile/share");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("url", "/"+url);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 文章页面     *     * @param id 文章标识     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/articleUrl")    public ModelAndView articleNoDesc(HttpServletRequest request,String id,@RequestParam(required = false) String memberId,@RequestParam(required = false) String url){        ModelAndView modelAndView=new ModelAndView("/mobile/"+url);        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("article",webArticleService.selectByPrimaryKey(id));        return modelAndView;    }    /**     * 搜索     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/search")    public ModelAndView search(HttpServletRequest request,@RequestParam(required = false) String memberId,String cityId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        List<HostSearch> list=hostSearchService.acceptList(new HostSearchVo(cityId));        ModelAndView modelAndView=new ModelAndView("/mobile/search");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("cityId", cityId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("hostSearchList", list);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的推广人员     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/myMember")    public ModelAndView myMember(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/myMember");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的推广人员信息     *     * @param hostWithdrawVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @author shengQiang yu     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/hostWithdraw/page",method = RequestMethod.POST)    public ReturnEntity hostWithdrawPage(HostWithdrawVo hostWithdrawVo, int pageSize, int pageNum){        ReturnEntity returnEntity = hostWithdrawService.page(hostWithdrawVo,pageSize,pageNum);        if(returnEntity.getData()!=null){            List<HostWithdraw> list = (List<HostWithdraw>)returnEntity.getData();            for(HostWithdraw hostWithdraw:list){                hostWithdraw.setCreateTimeStr(DateUtil.getDateText(hostWithdraw.getCreateTime(),"yyyy-MM-dd"));            }        }        return returnEntity;    }    /**     * 我的积分     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/myScore")    public ModelAndView myScore(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/myScore");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的积分查询     *     * @param webScoreRecordVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @author shengQiang yu     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/myScore/page",method = RequestMethod.POST)    public ReturnEntity myScorePage(WebScoreRecordVo webScoreRecordVo, int pageSize, int pageNum){        ReturnEntity returnEntity = webScoreRecordService.page(webScoreRecordVo,pageSize,pageNum);        return returnEntity;    }    /**     * 我的订单     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/myDetail")    public ModelAndView myDetail(HttpServletRequest request,@RequestParam(required = false) String memberId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        ModelAndView modelAndView=new ModelAndView("/mobile/myDetail");        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 我的订单查询     *     * @param webProductOrderVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @author shengQiang yu     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/myDetail/page",method = RequestMethod.POST)    public ReturnEntity myDetailPage(WebProductOrderVo webProductOrderVo, int pageSize, int pageNum){        ReturnEntity returnEntity = webProductOrderService.page(webProductOrderVo,pageSize,pageNum);        return returnEntity;    }    /**     * 获取热卖信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/hotHost",method = RequestMethod.POST)    public ReturnEntity acceptArticle(String cityId, @RequestParam(defaultValue="-1") int num){        List<HostItem> hostItemList= hostItemService.acceptList(new HostItemVo(cityId, HostBaseContent.HOST_HOT_SALE_STATE_KQ));        List<HostItem> hostItemResultList=new ArrayList<HostItem>();        if(num<0){            return new ReturnEntity(hostItemList);        }else{            if(hostItemList!=null&&hostItemList.size()>0){                int i=0;                for(HostItem hostItem:hostItemList){                    if(i<num){                        hostItemResultList.add(hostItem);                    }else{                        break;                    }                    i++;                }            }            return new ReturnEntity(hostItemResultList);        }    }    /**     * 兑换信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @Transactional    @RequestMapping(value = "/orderSave",method = RequestMethod.POST)    public ReturnEntity orderSave(WebProductOrder webProductOrder) throws ParseException {        WebProduct webProduct=webProductService.selectByPrimaryKey(webProductOrder.getProductId());        WebMember webMember=webMemberService.selectByPrimaryKey(webProductOrder.getMemberId());        if(webMember==null||webProduct==null){            return new ReturnEntity(BaseConstant.FAIL,"参数错误");        }        if(webMember.getScore()<webProduct.getScore()){            return new ReturnEntity(BaseConstant.FAIL,"积分不足");        }        webProductOrder.setId("E"+BaseUtil.uId());        webProductOrder.setOperateStatus(BaseConstant.BASE_OPERATOR_STATUS_WCL);        webProductOrder.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        webProductOrder.setCreateTime(new Date());        webProductOrder.setUpdateTime(new Date());        webProductOrder.setName(webProduct.getName());        webProductOrder.setScore(webProduct.getScore());        webProductOrder.setImages(webProduct.getImages());        webProductOrder.setCoverImage(webProduct.getCoverImage());        int num=webProductOrderService.insert(webProductOrder);        if(num<0){            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        }else{            webMember.setScore(webMember.getScore()-webProductOrder.getScore());            webMemberService.updateByPrimaryKey(webMember);            WebScoreRecord webScoreRecord=new WebScoreRecord(null);            webScoreRecord.setExtraId(webProductOrder.getId());            webScoreRecord.setScore(webProductOrder.getScore());            webScoreRecord.setMemberId(webMember.getId());            webScoreRecord.setRecordType(WebBaseContent.WEB_RECORD_TYPE_JFDH);            webScoreRecord.setDescripts("兑换商品【"+webProduct.getName()+"】，消费"+webProductOrder.getScore()+"个积分");            webScoreRecordService.insert(webScoreRecord);            webProduct.setSaleNum(webProduct.getSaleNum()+1);            webProductService.updateByPrimaryKey(webProduct);        }        return new ReturnEntity();    }    /**     * 建议信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/adviseSave",method = RequestMethod.POST)    public ReturnEntity adviseSave(HostAdvise hostAdvise) throws ParseException {        hostAdvise.setOperateStatus(BaseConstant.BASE_OPERATOR_STATUS_WCL);        hostAdvise.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        hostAdvise.setCreateTime(new Date());        hostAdvise.setUpdateTime(new Date());        int num=0;        if(StrUtil.isEmpty(hostAdvise.getId())){            hostAdvise.setId(BaseUtil.uId());            num=hostAdviseService.insert(hostAdvise);        }else{            hostAdvise.setOperateResult("");            num=hostAdviseService.updateByPrimaryKey(hostAdvise);        }        if(num<0){            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        }        return new ReturnEntity();    }    /**     * 申请入驻     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     * */    @RequestMapping(value="/settled")    public ModelAndView settled(HttpServletRequest request,@RequestParam(required = false) String memberId,String itemId){        WebMember webMember = check(memberId, BaseConstant.WX_STATE_ONE);        if (webMember == null) {            return checkModelAndView;        }        List<HostSettled> hostSettledList=hostSettledService.acceptList(new HostSettledVo(itemId,memberId));        ModelAndView modelAndView=new ModelAndView("/mobile/settled");        if(hostSettledList!=null&&hostSettledList.size()>0){            modelAndView.addObject("hostSettled", hostSettledList.get(0));        }        modelAndView.addObject("memberId", memberId);        modelAndView.addObject("num", hostSettledService.selectCountNum(new HostSettledVo(itemId,memberId)));        modelAndView.addObject("webMember", webMember);        modelAndView.addObject("itemId", itemId);        modelAndView.addObject("jSTicketShareResponse",Share(request,webMember));        return modelAndView;    }    /**     * 入驻申请信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/settledSave",method = RequestMethod.POST)    public ReturnEntity settledSave(HostSettled hostSettled) throws ParseException {        WebMember webMember =webMemberService.selectByPrimaryKey(hostSettled.getMemberId());        if(webMember!=null&&StrUtil.isEmpty(webMember.getName())){            return new ReturnEntity(BaseConstant.FAIL,"请先绑定信息");        }        hostSettled.setId(BaseUtil.uId());        hostSettled.setCheckStatus(BaseConstant.BASE_CHECK_STATUS_DSH);        hostSettled.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        hostSettled.setCreateTime(new Date());        hostSettled.setUpdateTime(new Date());        int  num=hostSettledService.insert(hostSettled);        if(num<0){            return new ReturnEntity(BaseConstant.FAIL,"申请失败");        }        return new ReturnEntity();    }    /**     * 提现信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/withdrawSave",method = RequestMethod.POST)    @Transactional    public ReturnEntity withdrawSave(HostWithdraw hostWithdraw) throws ParseException {        WebMember webMember=webMemberService.selectByPrimaryKey(hostWithdraw.getMemberId());        if(webMember==null){            return new ReturnEntity(BaseConstant.FAIL,"参数错误");        }else if(StrUtil.isEmpty(webMember.getBankNo())){            return new ReturnEntity(BaseConstant.FAIL,"请先去我的名片填写银行信息，才能提现！");        }else if(webMember.getMoney()<hostWithdraw.getMoney()){            return new ReturnEntity(BaseConstant.FAIL,"您最多只能提现"+hostWithdraw.getMoney()+"元");        }        hostWithdraw.setId(BaseUtil.uId());        hostWithdraw.setBankNo(webMember.getBankNo());        hostWithdraw.setWithdrowStatus(HostBaseContent.HOST_WITHDRAW_STATUS_DTX);        hostWithdraw.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        hostWithdraw.setCreateTime(new Date());        hostWithdraw.setUpdateTime(new Date());        int num=hostWithdrawService.insert(hostWithdraw);        if(num<0){            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        }else{           webMember.setMoney(webMember.getMoney()-hostWithdraw.getMoney());           webMemberService.updateByPrimaryKey(webMember);        }        return new ReturnEntity();    }    /**     * 申请经纪人信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/applySave",method = RequestMethod.POST)    public ReturnEntity applySave(HostApply hostApply) throws ParseException {        hostApply.setCheckStatus(BaseConstant.BASE_CHECK_STATUS_DSH);        hostApply.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        hostApply.setCreateTime(new Date());        hostApply.setUpdateTime(new Date());        int num=0;        if(StrUtil.isEmpty(hostApply.getId())){            hostApply.setId(BaseUtil.uId());            num=hostApplyService.insert(hostApply);        }else{            num=hostApplyService.updateByPrimaryKey(hostApply);        }        if(num<0){            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        }        return new ReturnEntity();    }    /**     * 用户信息修改     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/memberSave",method = RequestMethod.POST)    public ReturnEntity memberSave(WebMember webMember,String code) throws ParseException {        List<WebCheckCode> list=webCheckCodeService.acceptList(new WebCheckCodeVo(webMember.getPhone(),code,BaseConstant.BASE_USE_STATUS_WSY));        if(list!=null&&list.size()>0){            WebCheckCode webCheckCodes=null;            boolean falge=false;            for (WebCheckCode webCheckCode:list) {               if(DateUtil.currentDate().getTime()<=webCheckCode.getEndTime().getTime()){                   webCheckCodes=webCheckCode;                   falge=true;               }            }            if(falge){                WebMember webMember1=webMemberService.selectByPrimaryKey(webMember.getId());                webMember1.setName(webMember.getName());                webMember1.setPhone(webMember.getPhone());                webMember1.setBankNo(webMember.getBankNo());                int num=webMemberService.updateByPrimaryKey(webMember1);                if(num<0){                    return new ReturnEntity(BaseConstant.FAIL,"操作失败");                }else{                    if(webCheckCodes!=null){                        webCheckCodes.setUseTime(new Date());                        webCheckCodes.setUseStatus(BaseConstant.BASE_USE_STATUS_YSY);                        webCheckCodeService.updateByPrimaryKey(webCheckCodes);                    }                }                return new ReturnEntity();            }else{                return new ReturnEntity(BaseConstant.FAIL,"验证码已失效");            }        }else{            return new ReturnEntity(BaseConstant.FAIL,"验证码错误");        }    }    /**     * 非验证码校验，用户更改     * @param webMember     * @return     */    @RequestMapping(value = "/memberSaveNotCheckCode",method = RequestMethod.POST)    public ReturnEntity memberSaveNotCheckCode(WebMember webMember) {        WebMember webMember1 = webMemberService.selectByPrimaryKey(webMember.getId());        if (StringUtils.equals(webMember.getCardType(), BaseConstant.WEB_MEMBER_CARD_TYPE_TWO)) {            // 如果是门店经纪人，需要验证，暂时可以通用验证码            /*WebMemberVo webMemberSearch = new WebMemberVo();            webMemberSearch.setShopNumber(webMember.getShopNumber());            List<WebMember> list = webMemberService.acceptList(webMemberSearch);            if (list != null && list.size() > 0) {                if (!StringUtils.equals(webMember.getId(), list.get(0).getId())) {                    return new ReturnEntity(BaseConstant.FAIL,"该门店验证码已被使用");                }            }*/            // 查看验证码是否有效            HostShop hostShopSearch = new HostShop();            hostShopSearch.setNumber(webMember.getShopNumber());            List<HostShop> hostShopList = hostShopService.select(hostShopSearch);            if (hostShopList == null || hostShopList.size() == 0) {                return new ReturnEntity(BaseConstant.FAIL,"未查询到门店验证码，请联系管理员");            }            webMember1.setShopNumber(webMember.getShopNumber());        } else {            webMember1.setShopNumber("");        }        webMember1.setName(webMember.getName());        webMember1.setCardType(webMember.getCardType());        webMember1.setIdCard(webMember.getIdCard());        webMember1.setPhone(webMember.getPhone());        webMember1.setBankNo(webMember.getBankNo());        int num = webMemberService.updateByPrimaryKey(webMember1);        if (num < 0) {            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        }        return new ReturnEntity();    }    /**     * 报备信息     *     * @author shengQiang yu     * @date 2019-4-25 16:53:29     */    @RequestMapping(value = "/reportSave",method = RequestMethod.POST)    public ReturnEntity reportSave(HostReport hostReport, String code) throws ParseException {        hostReport.setId(BaseUtil.uId());        hostReport.setReportState(HostBaseContent.HOST_REPORT_STATE_KHBB);        hostReport.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);        if(StrUtil.isNotEmpty(hostReport.getUseTimeStr())){            hostReport.setUseTime(DateUtil.getTextDate(hostReport.getUseTimeStr(),"yyyy-MM-dd HH:mm"));        }        hostReport.setCreateTime(new Date());        hostReport.setUpdateTime(new Date());        int num = hostReportService.insert(hostReport);        if (num < 0) {            return new ReturnEntity(BaseConstant.FAIL,"操作失败");        } else {            HostItem hostItem=hostItemService.selectByPrimaryKey(hostReport.getItemId());            if(hostItem!=null&&StrUtil.isNotEmpty(hostItem.getAreaId())){                HostArea hostArea=hostAreaService.selectByPrimaryKey(hostItem.getAreaId());                if(hostArea!=null&&StrUtil.isNotEmpty(hostArea.getUserId())){                    SysUser sysUser= sysUserService.selectByPrimaryKey(hostArea.getUserId());                    if(sysUser!=null&&StrUtil.isNotEmpty(sysUser.getUserPhone())){                        JuHeResultVo juHeResultVo=SmsApi.smsSend(sysUser.getUserPhone(),SmsApi.tpl_id,"#code#=00000000&#m#=15");                    }                }            }        }        return new ReturnEntity();    }    /**     * 分页积分商品查询     *     * @param webProductVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @author shengQiang yu     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/product/page",method = RequestMethod.POST)    public ReturnEntity productPage(WebProductVo webProductVo, int pageSize, int pageNum){        ReturnEntity returnEntity = webProductService.page(webProductVo,pageSize,pageNum);        return returnEntity;    }    /**     * 分页产品查询     *     * @param hostItemVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @author shengQiang yuwebBannerList     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/hostItem/page",method = RequestMethod.POST)    public ReturnEntity page(HostItemVo hostItemVo, int pageSize, int pageNum){        ReturnEntity returnEntity = hostItemService.pageLeftDto(hostItemVo, pageSize, pageNum);        return returnEntity;    }    /**     * 发送短信验证码     *     * @param phone 手机号     * @author shengQiang yu     * @date 2019-7-1 15:25:38     */    @RequestMapping(value = "/smsSend")    public ReturnEntity smsSend(String phone){        String code=RandomUtil.randomNumbers(6);        JuHeResultVo juHeResultVo=SmsApi.smsSend(phone,SmsApi.tpl_id,"#code#="+code+"&#m#=15");        if(juHeResultVo.getError_code()==0){            return webCheckCodeService.addOrUpdate(new WebCheckCodeVo(phone,code,DateUtil.getMinuteOneDate(new Date(),15),BaseConstant.BASE_USE_STATUS_WSY),null);        }else{            return new ReturnEntity(BaseConstant.FAIL,juHeResultVo.getReason());        }    }    /**     * 分页查询     *     * @param hostReportVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @return ReturnEntity 对象     * @author shengQiang yu     * @date 2019-7-1 15:25:15     */    @RequestMapping(value = "/hostReport/page",method = RequestMethod.POST)    public ReturnEntity page(HostReportVo hostReportVo, int pageSize, int pageNum) {        ReturnEntity returnEntity = hostReportService.pageMember(hostReportVo,pageSize,pageNum);        if(returnEntity.getData()!=null){            List<HostReport> list = (List<HostReport>)returnEntity.getData();            for(HostReport hostReport:list){                hostReport.setPhone(hostReport.getPhone().substring(0,2)+"****"+hostReport.getPhone().substring(7));                // hostReport.setCreateTimeStr(DateUtil.getDateText(hostReport.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));            }        }        return returnEntity;    }    /**     * 分页查询我的佣金     *     * @param hostDetailVo 对象     * @param pageSize 展示数量     * @param pageNum 当前页面     * @return ReturnEntity 对象     * @author shengQiang yu     * @date 2019-7-1 15:25:15     */    @RequestMapping(value = "/hostDetail/page",method = RequestMethod.POST)    public ReturnEntity hostDetailPage(HostDetailVo hostDetailVo, int pageSize, int pageNum) {        ReturnEntity returnEntity = hostDetailService.page(hostDetailVo,pageSize,pageNum);        if(returnEntity.getData()!=null){            List<HostDetail> list = (List<HostDetail>)returnEntity.getData();            for(HostDetail hostDetail:list){                hostDetail.setCouserPhone(hostDetail.getCouserPhone().substring(0,2)+"****"+hostDetail.getCouserPhone().substring(7));                hostDetail.setCreateTimeStr(DateUtil.getDateText(hostDetail.getCreateTime(),"yyyy-MM-dd"));            }        }        return returnEntity;    }    /**     * 根据经纬度获取地址     */    @RequestMapping(value = "/acceptAddres")    public @ResponseBody    ReturnEntity acceptAddres(String location) {        try {            String address= GaoDeApi.acceptAddress(location);            return new ReturnEntity(address);        } catch (Exception e) {            e.printStackTrace();        }        return new ReturnEntity(BaseConstant.FAIL,"获取失败");    }    /**     * 获取首页分享图片     * */    @RequestMapping(value = "/acceptShareHomePic/{type}")    public @ResponseBody    ReturnEntity acceptShareHomePic(HttpServletResponse response, HttpServletRequest request, @PathVariable String type, String memberId)  {       ReturnEntity returnEntity=new ReturnEntity();        JSONObject jsonObject=new JSONObject();        WebMember member=webMemberService.selectByPrimaryKey(memberId);        if(member==null){            returnEntity=new ReturnEntity(BaseConstant.FAIL,"用户不存在");            return returnEntity;        }        WebAccount webAccount=WxMemoryCacheClient.getSingleWxAccountInfo();        //获取相对路径        String homeUrl="/upload/share/"+memberId+".jpg";        String realPath= HttpUtil.getRealPath(request);        File file = new File(realPath+homeUrl);        if(file.exists()){            //存在            returnEntity=new ReturnEntity(homeUrl);            return returnEntity;        }else{        }        //如果文件夹不存在则创建        File dicFile =new File(realPath+"upload/share/");        if  (!dicFile .exists()  && !dicFile .isDirectory()){            dicFile .mkdir();        }        String absultPic=null;        EwmMessage ewmMessage=new EwmMessage();        ewmMessage.setScene(memberId);        ewmMessage.setWidth(220);        Map<String,Object> ewmPicMap= null;        try {            ewmPicMap = WxApiClient.xcxAcceptEwm(realPath+"upload/share",memberId+"ewmxcx.png",ewmMessage,false);            int errcode=(Integer) ewmPicMap.get("errcode");            if(errcode!=0){                String errmsg=(String)ewmPicMap.get("errmsg");                returnEntity=new ReturnEntity(BaseConstant.FAIL,errmsg);                return returnEntity;            }            absultPic=(String)ewmPicMap.get("path");        } catch (IOException e) {            returnEntity=new ReturnEntity(BaseConstant.FAIL,"分享图片创建二维码错误");            return returnEntity;        }        if(Pic.combinePic(realPath+homeUrl,realPath+"image/spBg1.jpg",absultPic,member.getHeadImage(),BaseUtil.decodeBase64(member.getNickName()))){            returnEntity=new ReturnEntity(homeUrl);            return returnEntity;        }else{            returnEntity=new ReturnEntity(BaseConstant.FAIL,"分享图片生成失败");            return returnEntity;        }    }    /**     * 通用验证     * */    protected WebMember check(String id, String state){        if (StringUtil.isNotEmpty(id)) {            WebMember webMember = webMemberService.selectByPrimaryKey(id);            if (webMember != null) {                // 查看登录状态，如果非登录，跳转到登录页面               if (StringUtil.isEmpty(webMember.getLoginStatus()) || StringUtils.equals(webMember.getLoginStatus(), BaseConstant.WEB_MEMBER_LOGIN_NO)) {                    checkModelAndView = new ModelAndView("redirect:/weChat/loginPage?memberId=" + id);                    return null;                }                //设置会员昵称                if (StringUtil.isNotEmpty(webMember.getNickName())) {                    webMember.setNickName(BaseUtil.decodeBase64(webMember.getNickName()));                }                return webMember;            }        }        checkModelAndView = new ModelAndView("redirect:/weChat/loginPage?memberId=" + id);        return null;    }    /**     * 通用分享可设置     * */    protected JSTicketShareResponse Share(HttpServletRequest request,WebMember webMember){        WebAccount wxAccountInfo= WxMemoryCacheClient.getSingleWxAccountInfo();        log.info("phone:"+wxAccountInfo.toString());        String url= wxAccountInfo.getBaseUrl()+request.getServletPath();        String c=request.getQueryString();        if(StringUtil.isNotEmpty(c)){            url=url+"?"+c;        }        //设置js分享        JSTicketShareResponse jsTicketShareResponse = WxApiClient.getJSTicketShareResponse(url);        log.info("phone:"+jsTicketShareResponse);        List<WebShare> webShareList=webShareService.acceptList(new WebShareVo());        if(webShareList!=null&&webShareList.size()>0){             WebShare dbShare=webShareList.get(0);            if(dbShare!=null&&jsTicketShareResponse!=null){                jsTicketShareResponse.setFxTitle(dbShare.getShareTitle());                jsTicketShareResponse.setFxImgUrl(wxAccountInfo.getBaseUrl()+ dbShare.getSharePic());                jsTicketShareResponse.setFxDesc(dbShare.getShareDesc());                jsTicketShareResponse.setFxUrl(dbShare.getShareUrl()+webMember.getCardNo());                jsTicketShareResponse.setAppid(wxAccountInfo.getAppId());            }        }        return jsTicketShareResponse;    }    /**     * 小程序获取用户openid信息     * */    @RequestMapping(value = "/xcxAcceptCreateUser")    public @ResponseBody ReturnEntity xcxAcceptCreateUser(String code){        Map<String,Object> map= WxApiClient.xcxAcceptUserInfo(code);        String unionid=(String)map.get("unionid");        String xcxOpenid=(String)map.get("openid");        if(StringUtil.isNotEmpty(xcxOpenid)){            WebMember member=webMemberService.selectEntityByOpenid(xcxOpenid);            if(member == null){                // 用户不存在                member=new WebMember();                int cardNo = webMemberService.selectMaxId();                if (cardNo < BaseConstant.MEMBER_MIN_DEFAULT_ID) {                    cardNo = BaseConstant.MEMBER_MIN_DEFAULT_ID;                } else {                    cardNo = cardNo + 1;                }                member.setId(BaseUtil.uId());                member.setCardNo(String.valueOf(cardNo));                member.setOpenid(xcxOpenid);                member.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);                member.setCreateTime(new Date());                member.setGrade("1");                member.setUnionid(unionid);                member.setMoney(0.0);                int ids=webMemberService.insert(member);                if(ids>0){                    map.put("memberId",member.getId());                    return new ReturnEntity(map);                }else{                    return new ReturnEntity(BaseConstant.FAIL,"会员创建错误");                }            }else{                map.put("memberId",member.getId());                return new ReturnEntity(map);            }        }else{            return new ReturnEntity(BaseConstant.FAIL,"接口错误");        }    }    /**     * 小程序绑定用户信息     * */    @RequestMapping(value = "/xcxBindUser")    public @ResponseBody ReturnEntity xcxBindUser(WebMemberVo webMemberVo){        WebMember member=webMemberService.selectByPrimaryKey(webMemberVo.getId());        if(member == null){            return new ReturnEntity(BaseConstant.FAIL,"会员绑定信息错误");        }else{            member.setNickName(BaseUtil.encodeBase64String(webMemberVo.getNickName()));            member.setHeadImage(webMemberVo.getHeadImage());           int ids= webMemberService.updateByPrimaryKey(member);           if(ids>0){               return new ReturnEntity(member);           }else{               return new ReturnEntity(BaseConstant.FAIL,"会员插入信息错误");           }        }    }    /**     * 小程序获取用户信息     * */    @RequestMapping(value = "/xcxAcceptUserInfo")    public @ResponseBody    Map<String,Object> xcxAcceptUserInfo(String code){        Map<String,Object> map= WxApiClient.xcxAcceptUserInfo(code);        String unionid=(String)map.get("unionid");        String xcxOpenid=(String)map.get("openid");        if(StringUtil.isNotEmpty(unionid)&&StringUtil.isNotEmpty(xcxOpenid)){            setXcxOpenid(unionid,xcxOpenid);        }        WebAccount webAccount= WxMemoryCacheClient.getSingleWxAccountInfo();        List<WebShare> webShareList=webShareService.acceptList(new WebShareVo());        if(webShareList!=null&&webShareList.size()>0){            WebShare dbShare=webShareList.get(0);            if(dbShare!=null){                map.put("title", dbShare.getShareTitle());                map.put("desc",dbShare.getShareDesc());                map.put("imageUrl",webAccount.getBaseUrl()+ dbShare.getSharePic());            }        }        return map;    }    private void setXcxOpenid(String unionid,String xcxOpenid){        WebUnionid webUnionid= webUnionidService.selectByPrimaryKey(unionid);        if(webUnionid!=null&&!(xcxOpenid.equals(webUnionid.getXcxOpenid()))){            webUnionid.setXcxOpenid(xcxOpenid);            webUnionidService.updateByPrimaryKey(webUnionid);        }else if(webUnionid==null){            webUnionid=new WebUnionid();            webUnionid.setUnionid(unionid);            webUnionid.setXcxOpenid(xcxOpenid);            webUnionid.setCreateTime(new Date());            webUnionidService.insert(webUnionid);        }    }}